<?php
/**
 *
 *  
 * Date: 2024/1/16
 * Email: < >
 */


namespace app\traits;

use app\api\model\GameCarsPlayer as GameCarsPlayerDB;
use Illuminate\Support\Carbon;

trait GameCar
{

    //北京赛车游戏
    function ranking()
    {
        $arr = range(1, 10);
        shuffle($arr);
        return $arr;
    }

    //根据名次获取中奖信息
    function rank2type($ranking,$v,$date_id){
        array_walk($v,function (&$v) use ($ranking,$date_id){
            foreach ($ranking as $i=>$j){
                //前十名投注
                if($v['buy_type']=='type'.($i+1)&&$v['buy_car_id']==$ranking[$i]){
                    $v['is_got'] = 1;
                }
                //冠亚组合
                if($v['buy_type']=='championship'){
                    $championship = array_slice($ranking, 0, 2);
                    $championship_v = explode(",", $v['buy_car_id']);
                    sort($championship);
                    if($championship==$championship_v){
                        $v['is_got'] = 1;
                    }
                }
            }
        });
        return  $v;
    }

}